package org.lease.web.controller;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import org.lease.common.result.Result;
import org.lease.model.dto.AppointmentDTO;
import org.lease.model.entity.ViewAppointment;
import org.lease.model.enums.AppointmentStatus;
import org.lease.model.query.AppointmentPageQuery;
import org.lease.service.ViewAppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/appointment")
public class ViewAppointmentController {
    @Autowired
    private ViewAppointmentService viewAppointmentService;

    @Operation(summary = "分页查询预约信息")
    @GetMapping("/page")
    public Result<IPage<AppointmentDTO>> page(AppointmentPageQuery query) {
        IPage<AppointmentDTO> page = viewAppointmentService.pageQueryAppointment(query);
        return Result.success(page);
    }

    @Operation(summary = "根据ID更新预约状态")
    @PostMapping("/updateStatusById")
    public Result updateStatusById(@RequestParam Long id, @RequestParam AppointmentStatus status) {
        viewAppointmentService.updateAppointmentStatus(id, status);
        return Result.success();
    }
}
